home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 3: Developer Tools / Linux Cubed Series 3 - Developer Tools.iso / devel / lang / tcl / xf2.3-p / xf2 / xf2.3 / src / xfprocFile.tcl < prev    next >
Encoding:
Text File  |  1993-11-20  |  6.2 KB  |  238 lines

  1. # Program: xf
  2. # Description: procedures that implement the file handling
  3. #
  4. # $Header: xfprocFile.tcl[2.4] Wed Mar 10 12:07:50 1993 garfield@garfield frozen $
  5.  
  6. proc XFProcFileInsert {} {
  7. ##########
  8. # Procedure: XFProcFileInsert
  9. # Description: insert additional source
  10. # Arguments: none
  11. # Returns: none
  12. # Sideeffects: none
  13. ##########
  14.  
  15.   XFEditSetStatus "Inserting file..."
  16.   XFProcFSBox "Select source file to insert:" {
  17.     global auto_path
  18.     global xfFSBox
  19.     global xfPath
  20.     global xfLoadPath
  21.     if {"$xfFSBox(name)" != "" &&
  22.         [file exists $xfFSBox(path)/$xfFSBox(name)]} {
  23.       XFEditSetStatus "Inserting...in progress"
  24.       if {[catch "source $xfFSBox(path)/$xfFSBox(name)" xfResult]} {
  25.         set xfTmpAutoPath ""
  26.         foreach xfCounter "$xfPath(src) [split $xfLoadPath :]" {
  27.           if {[file exists $xfCounter/tclIndex] &&
  28.               [lsearch $auto_path $xfCounter] == -1 &&
  29.               [lsearch $xfTmpAutoPath $xfCounter] == -1} {
  30.             lappend xfTmpAutoPath $xfCounter
  31.           }
  32.         }
  33.         set auto_path "$xfTmpAutoPath $auto_path"
  34.         catch "unset auto_index"
  35.         catch "unset auto_oldpath"
  36.         catch "unset auto_execs"
  37.         XFProcError "$xfResult"
  38.       } {
  39.         set xfTmpAutoPath ""
  40.         foreach xfCounter "$xfPath(src) [split $xfLoadPath :]" {
  41.           if {[file exists $xfCounter/tclIndex] &&
  42.               [lsearch $auto_path $xfCounter] == -1 &&
  43.               [lsearch $xfTmpAutoPath $xfCounter] == -1} {
  44.             lappend xfTmpAutoPath $xfCounter
  45.           }
  46.         }
  47.         set auto_path "$xfTmpAutoPath $auto_path"
  48.         catch "unset auto_index"
  49.         catch "unset auto_oldpath"
  50.         catch "unset auto_execs"
  51.       }
  52.       XFMiscBindWidgetTree .
  53.       XFEditSetShowWindows
  54.       XFEditSetPath .
  55.       XFEditSetStatus "Inserting file...done"
  56.     } {
  57.       XFEditSetStatus "Inserting file...aborted"
  58.     }
  59.   } {
  60.     XFEditSetStatus "Inserting file...aborted"
  61.   } {}
  62. }
  63.  
  64. proc XFProcFileLoad {} {
  65. ##########
  66. # Procedure: XFProcFileLoad
  67. # Description: load new file
  68. # Arguments: none
  69. # Returns: none
  70. # Sideeffects: none
  71. ##########
  72.  
  73.   XFEditSetStatus "Loading file..."
  74.  
  75.   XFProcFSBox "Select file to load:" {
  76.     global auto_path
  77.     global xfConf
  78.     global xfFSBox
  79.     global xfPath
  80.     global xfLoadPath
  81.     if {"$xfFSBox(name)" != "" &&
  82.         [file exists $xfFSBox(path)/$xfFSBox(name)]} {
  83.       XFEditSetStatus "Loading file...in progress"
  84.       XFMiscClearInterpreter
  85.       if {[catch "source $xfFSBox(path)/$xfFSBox(name)" xfResult]} {
  86.         set xfTmpAutoPath ""
  87.         foreach xfCounter "$xfPath(src) [split $xfLoadPath :]" {
  88.           if {[file exists $xfCounter/tclIndex] &&
  89.               [lsearch $auto_path $xfCounter] == -1 &&
  90.               [lsearch $xfTmpAutoPath $xfCounter] == -1} {
  91.             lappend xfTmpAutoPath $xfCounter
  92.           }
  93.         }
  94.         set auto_path "$xfTmpAutoPath $auto_path"
  95.         catch "unset auto_index"
  96.         catch "unset auto_oldpath"
  97.         catch "unset auto_execs"
  98.         XFProcError "$xfResult"
  99.       } {
  100.         set xfTmpAutoPath ""
  101.         foreach xfCounter "$xfPath(src) [split $xfLoadPath :]" {
  102.           if {[file exists $xfCounter/tclIndex] &&
  103.               [lsearch $auto_path $xfCounter] == -1 &&
  104.               [lsearch $xfTmpAutoPath $xfCounter] == -1} {
  105.             lappend xfTmpAutoPath $xfCounter
  106.           }
  107.         }
  108.         set auto_path "$xfTmpAutoPath $auto_path"
  109.         catch "unset auto_index"
  110.         catch "unset auto_oldpath"
  111.         catch "unset auto_execs"
  112.         set xfConf(programName) $xfFSBox(name)
  113.         set xfConf(programPath) $xfFSBox(path)
  114.         XFMiscUpdateModuleList
  115.       }
  116.       XFMiscBindWidgetTree .
  117.       XFEditSetShowWindows
  118.       XFEditSetPath .
  119.       XFEditSetStatus "Loading file...done"
  120.     } {
  121.       XFEditSetStatus "Loading file...aborted"
  122.     }
  123.   } {
  124.     XFEditSetStatus "Loading file...aborted"
  125.   } {}
  126. }
  127.  
  128. proc XFProcFileNew {} {
  129. ##########
  130. # Procedure: XFProcFileNew
  131. # Description: clear XF
  132. # Arguments: none
  133. # Returns: none
  134. # Sideeffects: none
  135. ##########
  136.  
  137.   if {[XFProcYesNo "Really remove all\nexisting definitions ?"]} {
  138.     XFMiscClearInterpreter
  139.   }
  140. }
  141.  
  142. proc XFProcFileQuit {{xfRetVal 0}} {
  143. ##########
  144. # Procedure: XFProcFileQuit
  145. # Description: quit XF
  146. # Arguments: {xfRetVal} - the return value
  147. # Returns: none
  148. # Sideeffects: none
  149. ##########
  150.  
  151.   if {[XFProcYesNo "Really Quit ?"]} {
  152.     XFMiscQuit $xfRetVal
  153.   }
  154. }
  155.  
  156. proc XFProcFileEnterTCL {} {
  157. ##########
  158. # Procedure: XFProcFileEnterTCL
  159. # Description: call the tcl-code input box
  160. # Arguments: none
  161. # Returns: none
  162. # Sideeffects: none
  163. ##########
  164.  
  165.   XFReadBox
  166. }
  167.  
  168. proc XFProcFileSave {} {
  169. ##########
  170. # Procedure: XFProcFileSave
  171. # Description: save the script under current name
  172. # Arguments: none
  173. # Returns: none
  174. # Sideeffects: none
  175. ##########
  176.   global xfConf
  177.   global xfStatus
  178.  
  179.   XFEditSetStatus "Saving file..."
  180.   if {"$xfConf(programName)" != "" &&
  181.       [XFMiscIsDir $xfConf(programPath)]} {
  182.     XFEditSetStatus "Saving...in progress"
  183.     set xfStatus(saving) 0
  184.     XFSaveModules $xfConf(programPath)/$xfConf(programName)
  185.     if {$xfConf(writeTclIndex)} {
  186.       XFSaveTclIndex
  187.     }
  188.     XFEditSetStatus "Saving file...done"
  189.   } {
  190.     XFEditSetStatus "Saving file...aborted"
  191.   }
  192. }
  193.  
  194. proc XFProcFileSaveAs {} {
  195. ##########
  196. # Procedure: XFProcFileSaveAs
  197. # Description: save the script under new name
  198. # Arguments: none
  199. # Returns: none
  200. # Sideeffects: none
  201. ##########
  202.  
  203.   global xfConf
  204.   global xfFSBox
  205.  
  206.   XFEditSetStatus "Saving file as..."
  207.   auto_load XFFSBox
  208.   set xfFSBox(path) $xfConf(programPath)
  209.   XFProcFSBox "Select filename to save to:" {
  210.     global moduleList
  211.     global xfConf
  212.     global xfStatus
  213.     if {"$xfFSBox(name)" != "" &&
  214.         [XFMiscIsDir $xfFSBox(path)]} {
  215.       XFEditSetStatus "Saving file as...in progress"
  216.       if {[lsearch [array names moduleList] $xfFSBox(name)] != -1} {
  217.         XFEditSetStatus "Saving product...aborted"
  218.         XFProcError "The given name is used as a development module !"
  219.       } {
  220.         XFMiscUpdateModuleList
  221.         set xfStatus(saving) 0
  222.         XFSave $xfFSBox(path)/$xfFSBox(name)
  223.         if {$xfConf(writeShellScript)} {
  224.       XFSaveScript $xfFSBox(name)
  225.         }
  226.         XFEditSetStatus "Saving file as...done"
  227.       }
  228.     } {
  229.       XFEditSetStatus "Saving file as...aborted"
  230.     }
  231.   } {
  232.     XFEditSetStatus "Saving file as...aborted"
  233.   } "$xfConf(programName)"
  234. }
  235.  
  236. # eof
  237.  
  238.